package com.xxx.video.main.presenters;


import android.content.Context;

import androidx.annotation.NonNull;

import com.xxx.video.commen.presenters.BasePresenter;
import com.xxx.video.commen.utils.ResponseUtils;
import com.xxx.video.main.beans.RecommendAllListBean;
import com.xxx.video.network.listeners.CommonResponseListener;
import com.xxx.video.network.utils.NetWorkUtils;

public class HomeIndexPresenter extends BasePresenter<IHomeIndexView> {
    public HomeIndexPresenter(@NonNull Context context, IHomeIndexView baseView) {
        super(context, baseView);
    }

    public void getRecommendAllList(int type, int page) {
        NetWorkUtils.getInstance().getRecommendAllList(type, page, new CommonResponseListener<RecommendAllListBean>() {

            @Override
            public void onSuccess(RecommendAllListBean successOb, String result) {
                if (ResponseUtils.getInstance().isNoError(successOb)) {
                    if (getBaseView() != null) {
                        getBaseView().initData2View(successOb.page.list);
                    }
                } else {
                    if (getBaseView() != null) {
                        getBaseView().showRootLayoutStatus(3);
                    }
                }
            }

            @Override
            public void onFailure(Object failureObj) {
                if (getBaseView() != null) {
                    getBaseView().showRootLayoutStatus(3);
                }
            }
        });
    }
}
